package com.wmx.java_8.lambda;

import com.baomidou.mybatisplus.core.toolkit.support.Property;
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;

/**********************************
 * @author wmx
 * @date 2019/10/11 9:45
 * @description:
 * @version 1.0
 ************************************/
public class LambdaDemo {
    public static void main(String[] args) {
        FunctionalInterFaceDemo fif = (a, b) -> {
            return a + b;
        };
        System.out.println(fif.operation(2, 3));
        Comparator<Integer> comparator = (a, b) -> {
            return a.compareTo(b);
        };

        System.out.println(comparator.compare(4, 20));
        System.out.println(comparator.compare(20, 4));
        System.out.println(comparator.compare(4, 4));

        Function<String, Integer> function = a -> {
            return Integer.parseInt(a);
        };
        //方法推导
        Function<String, Integer> function1 = Integer::parseInt;

        System.out.println(function.apply("1233"));

        BiFunction<String, String, Integer> biFunction = (a, b) -> {
            return Integer.parseInt(a) + Integer.parseInt(b);
        };


        System.out.println(biFunction.apply("1","2"));



    }
}
